<template>
   <div ref="scoring" class="scoring ewrer">
   </div>
</template>
<script>
import { getScore } from '@/api/score.js'

export default {
   name: '',
   components: {

   },
   mixins: [],
   props: {

   },
   data() {
      return {
         internalScoreResult: {}
      }
   },
   computed: {

   },
   watch: {

   },
   mounted() {
      const companyId = this.$route.query.companyId;
      const fundId = this.$route.query.id
      getScore({
         companyId,
         fundId,
      }).then(res => {
         this.internalScoreResult = res.data.internalScoreResult;
         this.renderChart()
      })
      
   },

   methods: {
      renderChart() {
         let chartInstance = this.$echarts.init(this.$refs.scoring);
         const value = [this.internalScoreResult.earnings,
         this.internalScoreResult.risk,
         this.internalScoreResult.portfolioManagement,
         this.internalScoreResult.clause,
         this.internalScoreResult.managerMaturity,
         this.internalScoreResult.commercialization,
         this.internalScoreResult.internalResearch].map(value => value || 0)

         const max = Math.max.apply(null, value)
         let option = {
            title: {
            },
            radar: {
               // shape: 'circle',
               indicator: [
                  { name: '投资收益', max, },
                  { name: '投资风险', max, },
                  { name: '组合管理', max, },
                  { name: '投资条款', max, },
                  { name: '管理人员成熟度', max, },
                  { name: '商业化', max, },
                  { name: '内部调研', max, }
               ]
            },
            series: [
               {
                  type: 'radar',
                  data: [
                     {
                        value: value,
                     },
                  ]
               }
            ]
         };
         chartInstance.setOption(option);
      }
   }
};
</script>
<style lang='' scoped>
.scoring{
   width: 100%;
   height: 400px;
}
</style>